import { createRouter, createWebHistory } from "vue-router";
import Login from "@/views/Login.vue";
import Layout from "@/views/Layout.vue";
import AdminHome from "@/views/admin/AdminHome.vue";
import AdminManage from "@/views/admin/AdminManage.vue";
import AdminProfile from "@/views/admin/AdminProfile.vue";
import ConsultantHome from "@/views/consultant/ConsultantHome.vue";
import ConsultantAppointment from "@/views/consultant/ConsultantAppointment.vue";
import ConsultantProfile from "@/views/consultant/ConsultantProfile.vue";
import UserHome from "@/views/user/UserHome.vue";
import UserConsultant from "@/views/user/UserConsultant.vue";
import UserProfile from "@/views/user/UserProfile.vue";

// 定义路由关系
const routes = [
  { path: '/login', component: Login },  // 一级路由
  {
    path: '/',
    redirect: '/login',  // 重定向
    component: Layout,
    // 子路由
    children: [
      // 管理员路由
      { path: '/admin/home', name: "adminHome", component: AdminHome },
      { path: '/admin/manage', name: "adminManage", component: AdminManage },
      { path: '/admin/appointment', name: "adminAppointment", component: () => import('@/views/admin/AdminAppointment.vue') },
      { path: '/admin/profile', name: "adminProfile", component: AdminProfile },
      // 咨询师路由
      { path: '/consultant/home', name: "consultantHome", component: ConsultantHome },
      { path: '/consultant/appointment', name: "consultantAppointment", component: ConsultantAppointment },
      { path: '/consultant/profile', name: "consultantProfile", component: ConsultantProfile },
      // 用户路由
      { path: '/user/home', name: "userHome", component: UserHome },
      { path: '/user/consultant', name: "userConsultant", component: UserConsultant },
      { path: '/user/profile', name: "userProfile", component: UserProfile },
      {
        path: '/user/appointment',
        component: () => import('@/views/user/UserAppointment.vue')
      },
    ]
  },
];

// 创建路由器
const router = createRouter({
  history: createWebHistory(), // 路由模式
  routes: routes
});

// 导出暴露
export default router;